/**
 * @file struct-test.c
 * @author StudentWeis studentweis@gmail.com
 * @brief C 语言结构体学习：
 *      - 结构体变量、指针的定义与读写；
 * @version 0.1
 * @date 2021-12-06
 * 
 * @copyright Copyright (c) 2021
 * 
 */

#include <stdio.h>
#include <string.h>

/**
 * @brief 路由器结构体
 * 
 */
typedef struct
{
    char Type_Name[20];
    char Building_Name[20];
    int Floor_Number;
} Router;

void Print_Router(Router xRouter);
void Print_Router_Pointer(Router *xRouter);

/**
 * @brief main
 * 
 * @return int 
 */
int main()
{
    /* 结构体变量的使用 */
    Router My_Route;
    strcpy(My_Route.Type_Name, "AX1821");
    strcpy(My_Route.Building_Name, "成教");
    My_Route.Floor_Number = 2;
    Print_Router(My_Route);

    /* 结构体指针的使用 */    
    Router *My_Route_Pointer;
    My_Route_Pointer = &My_Route;
    Print_Router_Pointer(My_Route_Pointer);
    return 0;
}

/**
 * @brief 打印结构体变量
 * 
 * @param xRouter 结构体变量
 */
void Print_Router(Router xRouter)
{
    printf("Type Name: %s\r\n", xRouter.Type_Name);
    printf("Building Name: %s\r\n", xRouter.Building_Name);
    printf("Floor Number: %d\r\n", xRouter.Floor_Number);
}

/**
 * @brief 打印结构体指针
 * 
 * @param xRouter 结构体地址
 */
void Print_Router_Pointer(Router *xRouter)
{
    printf("Type Name: %s\r\n", xRouter->Type_Name);
    printf("Building Name: %s\r\n", xRouter->Building_Name);
    printf("Floor Number: %d\r\n", xRouter->Floor_Number);
}